home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / shareware / share_41 / assembler / examples / count < prev    next >
Encoding:
Text File  |  1991-05-15  |  627 b   |  26 lines

  1. ; NAME       count
  2. ; PURPOSE    counts the number of characters in text1 and puts result in number1
  3. ; DESIGN    
  4. ;            set counter to zero
  5. ;            load first charcter of text1
  6. ;            while character <> control code
  7. ;              increment counter
  8. ;              load next charcter of text1
  9. ;            endwhile
  10. ;            store count in number1
  11.  
  12. ; NOTE
  13. ;            ldrb loads a register with a single byte    
  14.  
  15.                                           
  16. mov r8, #0
  17. ldrb r6, [r4]
  18. .loop        
  19.   cmp r6, #13
  20.   beq done
  21.   add r8, r8, #1
  22.   add r4, r4, #1
  23.   ldrb r6, [r4]
  24.   b loop       
  25. .done  
  26. str r8, [r1]